getMetrics

open fun getMetrics(): @Nullable Array<SparseIntArray>(source)

Returns the currently-collected metrics in an array of SparseIntArray objects. The index of the array indicates which metric's data is stored in that SparseIntArray object. For example, results for total duration will be in the [TOTAL_INDEX] item.

The return value may be null if no metrics were tracked. This is especially true on releases earlier than API 24, as the FrameMetrics system does not exist on these earlier release. If the return value is not null, any of the objects at a given index in the array may still be null, which indicates that data was not being tracked for that type of metric. For example, if the FrameMetricsAggregator was created with a call to new FrameMetricsAggregator(TOTAL_DURATION | DRAW_DURATION), then the SparseIntArray at index INPUT_INDEX will be null.

For a given non-null SparseIntArray, the results stored are the number of samples at each millisecond value (rounded). For example, if a data sample consisted of total durations of 5.1ms, 5.8ms, 6.1ms, and 8.2ms, the SparseIntArray at [TOTAL_DURATION] would have key-value pairs (5, 1), (6, 2), (8, 1).

Return

An array whose index refers to the type of metric stored in that item's SparseIntArray object, e.g., data for TOTAL_DURATION is stored in the [TOTAL_INDEX] item.